<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>一张脑图带你掌握Git命令 | 俊劫的学习基地</title>
    <meta name="generator" content="VuePress 1.7.1">
    <link rel="icon" href="/favicon.ico">
    <meta name="description" content="俊劫的学习基地是俊劫的个人博客，用于记录学习笔记、分享音乐、书籍、旅行等个人兴趣的站点。">
    <meta name="keywords" content="俊劫,俊劫的博客,博客,个人博客,vue,vuejs,vuepress,vuepress-theme-reco">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/assets/css/0.styles.5f3e1891.css" as="style"><link rel="preload" href="/assets/js/app.070ad525.js" as="script"><link rel="preload" href="/assets/js/2.1d15da37.js" as="script"><link rel="preload" href="/assets/js/59.b74c2845.js" as="script"><link rel="preload" href="/assets/js/4.aab0e518.js" as="script"><link rel="prefetch" href="/assets/js/10.46adc9c3.js"><link rel="prefetch" href="/assets/js/11.4fa3a97f.js"><link rel="prefetch" href="/assets/js/12.d930e0cf.js"><link rel="prefetch" href="/assets/js/13.ac14e905.js"><link rel="prefetch" href="/assets/js/14.5db5f3a5.js"><link rel="prefetch" href="/assets/js/15.f912d397.js"><link rel="prefetch" href="/assets/js/16.dc881375.js"><link rel="prefetch" href="/assets/js/17.4b5e68db.js"><link rel="prefetch" href="/assets/js/18.e48da6e4.js"><link rel="prefetch" href="/assets/js/19.4a02bf41.js"><link rel="prefetch" href="/assets/js/20.8437ea4c.js"><link rel="prefetch" href="/assets/js/21.618c8e36.js"><link rel="prefetch" href="/assets/js/22.097f8d74.js"><link rel="prefetch" href="/assets/js/23.512dda35.js"><link rel="prefetch" href="/assets/js/24.2afceb8f.js"><link rel="prefetch" href="/assets/js/25.a7a02005.js"><link rel="prefetch" href="/assets/js/26.a79e1590.js"><link rel="prefetch" href="/assets/js/27.d0feb2c1.js"><link rel="prefetch" href="/assets/js/28.62b630e3.js"><link rel="prefetch" href="/assets/js/29.119f3256.js"><link rel="prefetch" href="/assets/js/3.8b40c051.js"><link rel="prefetch" href="/assets/js/30.5b11ce87.js"><link rel="prefetch" href="/assets/js/31.94ce824a.js"><link rel="prefetch" href="/assets/js/32.ed4f7508.js"><link rel="prefetch" href="/assets/js/33.c74281cf.js"><link rel="prefetch" href="/assets/js/34.ffb262b0.js"><link rel="prefetch" href="/assets/js/35.ada11000.js"><link rel="prefetch" href="/assets/js/36.edb96889.js"><link rel="prefetch" href="/assets/js/37.02fd03c3.js"><link rel="prefetch" href="/assets/js/38.4e0ec907.js"><link rel="prefetch" href="/assets/js/39.8cd27589.js"><link rel="prefetch" href="/assets/js/40.e59f0b3b.js"><link rel="prefetch" href="/assets/js/41.e3da8313.js"><link rel="prefetch" href="/assets/js/42.c847d1f4.js"><link rel="prefetch" href="/assets/js/43.13c84445.js"><link rel="prefetch" href="/assets/js/44.cbaa9acf.js"><link rel="prefetch" href="/assets/js/45.cb3a266d.js"><link rel="prefetch" href="/assets/js/46.0519c642.js"><link rel="prefetch" href="/assets/js/47.3373a57e.js"><link rel="prefetch" href="/assets/js/48.7efa5760.js"><link rel="prefetch" href="/assets/js/49.923721c8.js"><link rel="prefetch" href="/assets/js/5.07f41da3.js"><link rel="prefetch" href="/assets/js/50.839ac91d.js"><link rel="prefetch" href="/assets/js/51.f98cecb2.js"><link rel="prefetch" href="/assets/js/52.041f20b3.js"><link rel="prefetch" href="/assets/js/53.9464df60.js"><link rel="prefetch" href="/assets/js/54.a9ce67d2.js"><link rel="prefetch" href="/assets/js/55.9733d4b3.js"><link rel="prefetch" href="/assets/js/56.e67c1aa1.js"><link rel="prefetch" href="/assets/js/57.1335a8a7.js"><link rel="prefetch" href="/assets/js/58.83f617d8.js"><link rel="prefetch" href="/assets/js/6.dcf50b6e.js"><link rel="prefetch" href="/assets/js/60.6e3b00bd.js"><link rel="prefetch" href="/assets/js/61.cd335db9.js"><link rel="prefetch" href="/assets/js/62.ee277d48.js"><link rel="prefetch" href="/assets/js/63.2a34cfa5.js"><link rel="prefetch" href="/assets/js/64.a51989fe.js"><link rel="prefetch" href="/assets/js/65.3abfaea5.js"><link rel="prefetch" href="/assets/js/66.d4f35c55.js"><link rel="prefetch" href="/assets/js/67.2f070f74.js"><link rel="prefetch" href="/assets/js/68.c7da856f.js"><link rel="prefetch" href="/assets/js/69.6c15fcd4.js"><link rel="prefetch" href="/assets/js/7.10c46d97.js"><link rel="prefetch" href="/assets/js/70.68b6cf93.js"><link rel="prefetch" href="/assets/js/71.c49db210.js"><link rel="prefetch" href="/assets/js/72.7ffae8af.js"><link rel="prefetch" href="/assets/js/73.abb40ede.js"><link rel="prefetch" href="/assets/js/74.71723883.js"><link rel="prefetch" href="/assets/js/75.ab7e2e75.js"><link rel="prefetch" href="/assets/js/76.936112a6.js"><link rel="prefetch" href="/assets/js/8.ec9c3735.js"><link rel="prefetch" href="/assets/js/9.b555605d.js">
    <link rel="stylesheet" href="/assets/css/0.styles.5f3e1891.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container have-rightmenu" data-v-f848d4e8><div class="global-loading-wrapper" data-v-2c41f3eb data-v-f848d4e8 data-v-f848d4e8><div class="loader-main" data-v-2c41f3eb><img src="/assets/img/loading.a592e2e5.jpg" alt="loading" data-v-2c41f3eb></div></div> <div class="hide" data-v-f848d4e8><header class="navbar" data-v-f848d4e8><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/img/logo.png" alt="俊劫的学习基地" class="logo"> <span class="site-name">俊劫的学习基地</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">选择模式</h4> <ul class="color-mode-options"><li class="dark">深色模式</li><li class="light active">浅色模式</li><li class="read">阅读模式</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <ul class="suggestions" style="display:none;"></ul></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i></i>前端
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>文档教程</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/web/docs/imooc/wiki/" class="nav-link"><i class="iconfont reco-blog"></i>慕课教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/es6/" class="nav-link"><i class="iconfont reco-blog"></i>ES6 入门教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/wangdoc/javascript/" class="nav-link"><i class="iconfont reco-blog"></i>网道-JavaScript 教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/angular/" class="nav-link"><i class="iconfont reco-blog"></i>Angular 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/react/" class="nav-link"><i class="iconfont reco-blog"></i>React 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/vue/" class="nav-link"><i class="iconfont reco-blog"></i>Vue 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/node/" class="nav-link"><i class="iconfont reco-blog"></i>Node 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/babel/" class="nav-link"><i class="iconfont reco-blog"></i>Babel 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/webpack/" class="nav-link"><i class="iconfont reco-blog"></i>Webpack 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/typescript/" class="nav-link"><i class="iconfont reco-blog"></i>TypeScript 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/runoob/" class="nav-link"><i class="iconfont reco-blog"></i>菜鸟教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/docschina/" class="nav-link"><i class="iconfont reco-blog"></i>印记中文
</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-api"></i>索引
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/" class="nav-link"><i class="iconfont reco-category"></i>分类
</a></li><li class="dropdown-item"><!----> <a href="/tags/" class="nav-link"><i class="iconfont reco-tag"></i>标签
</a></li><li class="dropdown-item"><!----> <a href="/archives/" class="nav-link"><i class="iconfont reco-date"></i>归档
</a></li></ul></div></div><div class="nav-item"><a href="/bookshop/message-board/" class="nav-link"><i class="iconfont reco-suggestion"></i>留言板
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>关于
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>联系</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://github.com/alexwjj" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="/bookshop/linkme/" class="nav-link"><i class="iconfont reco-account"></i>关于我
</a></li></ul></li><li class="dropdown-item"><h4>博客</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://github.com/alexwjj/alexwjj.github.io" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-document"></i>本站源码
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://alexwjj.github.io/old-blog" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-document"></i>老版博客
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>其他</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/bookshop/friendslink/" class="nav-link"><i class="iconfont reco-friend"></i>友情链接
</a></li></ul></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-f848d4e8></div> <aside class="sidebar" data-v-f848d4e8><div class="personal-info-wrapper" data-v-34faaed8 data-v-f848d4e8><img src="/img/logo.png" alt="author-avatar" class="personal-img" data-v-34faaed8> <div class="author" data-v-34faaed8>
    俊劫
  </div> <div class="personal-info-details" data-v-34faaed8><div data-v-34faaed8>文章：<span data-v-34faaed8>54</span></div> <div data-v-34faaed8>地点：<span data-v-34faaed8>canton</span></div></div> <div class="slogan" data-v-34faaed8>
    just do it
  </div> <!----></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i></i>前端
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>文档教程</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/web/docs/imooc/wiki/" class="nav-link"><i class="iconfont reco-blog"></i>慕课教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/es6/" class="nav-link"><i class="iconfont reco-blog"></i>ES6 入门教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/wangdoc/javascript/" class="nav-link"><i class="iconfont reco-blog"></i>网道-JavaScript 教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/angular/" class="nav-link"><i class="iconfont reco-blog"></i>Angular 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/react/" class="nav-link"><i class="iconfont reco-blog"></i>React 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/vue/" class="nav-link"><i class="iconfont reco-blog"></i>Vue 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/node/" class="nav-link"><i class="iconfont reco-blog"></i>Node 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/babel/" class="nav-link"><i class="iconfont reco-blog"></i>Babel 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/webpack/" class="nav-link"><i class="iconfont reco-blog"></i>Webpack 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/typescript/" class="nav-link"><i class="iconfont reco-blog"></i>TypeScript 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/runoob/" class="nav-link"><i class="iconfont reco-blog"></i>菜鸟教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/docschina/" class="nav-link"><i class="iconfont reco-blog"></i>印记中文
</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-api"></i>索引
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/" class="nav-link"><i class="iconfont reco-category"></i>分类
</a></li><li class="dropdown-item"><!----> <a href="/tags/" class="nav-link"><i class="iconfont reco-tag"></i>标签
</a></li><li class="dropdown-item"><!----> <a href="/archives/" class="nav-link"><i class="iconfont reco-date"></i>归档
</a></li></ul></div></div><div class="nav-item"><a href="/bookshop/message-board/" class="nav-link"><i class="iconfont reco-suggestion"></i>留言板
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>关于
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>联系</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://github.com/alexwjj" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="/bookshop/linkme/" class="nav-link"><i class="iconfont reco-account"></i>关于我
</a></li></ul></li><li class="dropdown-item"><h4>博客</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://github.com/alexwjj/alexwjj.github.io" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-document"></i>本站源码
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://alexwjj.github.io/old-blog" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-document"></i>老版博客
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>其他</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/bookshop/friendslink/" class="nav-link"><i class="iconfont reco-friend"></i>友情链接
</a></li></ul></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><a href="/resource-tools/44207a5ef0a8a/" class="sidebar-link">网站资源</a></li><li><a href="/resource-tools/c618db4b32e39/" class="sidebar-link">Vue资源</a></li><li><a href="/resource-tools/4c19c32335465/" class="sidebar-link">工具库</a></li><li><a href="/resource-tools/c9e44ab0fce9a/" class="sidebar-link">面试资料</a></li><li><a href="/resource-tools/5f440c9bb4359/" class="sidebar-link">awesome-f2e-libs</a></li><li><a href="/resource-tools/9d5d91d08c126/" class="sidebar-link">文章收集</a></li><li><a href="/resource-tools/ed602e9a815f6/" class="sidebar-link">冴羽的博客</a></li><li><a href="/resource-tools/7566c0ff5a24c/" class="sidebar-link">Jony的博客</a></li><li><a href="/web/git/f85d0c838f3f3/" aria-current="page" class="active sidebar-link">一张脑图带你掌握Git命令</a></li><li><a href="/resource-tools/8396c1c08f1b6/" class="sidebar-link">一些前端开发的干货</a></li><li><a href="/pages/290a2fbb1e629/" class="sidebar-link">git 常用命令大全</a></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper bg-style-10"><div class="articleInfo-wrap" data-v-13f19dad><div class="articleInfo" data-v-13f19dad><ul class="breadcrumbs" data-v-13f19dad><li data-v-13f19dad><a href="/" title="首页" class="fa fa-laptop-house router-link-active" data-v-13f19dad></a></li> <li data-v-13f19dad><a href="/categories/?category=%E8%B5%84%E6%BA%90%E5%B7%A5%E5%85%B7" title="分类" data-v-13f19dad>资源工具</a></li> <!----> <!----></ul> <div class="info" data-v-13f19dad><div title="作者" class="author fa fa-user" data-v-13f19dad><a href="javascript:;" data-v-13f19dad>俊劫</a></div> <div title="创建时间" class="date fa fa-calendar-alt" data-v-13f19dad><a href="javascript:;" data-v-13f19dad>2020/09/17 18:43:29</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-content"></div></div></div> <h1><img src="">
            一张脑图带你掌握Git命令
          </h1> <div class="theme-vdoing-content content__default"><h2 id="说明"><a href="#说明" class="header-anchor">#</a> 说明</h2> <p>参考文章：</p> <p><a href="https://juejin.im/post/6869519303864123399#heading-9" target="_blank" rel="noopener noreferrer">【「一劳永逸」一张脑图带你掌握Git命令】--TianTianUp<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><a href="https://juejin.im/post/6844903635533594632" target="_blank" rel="noopener noreferrer">【您必须知道的 Git 分支开发规范】 - 稻草叔叔<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <h2 id="git-命令脑图"><a href="#git-命令脑图" class="header-anchor">#</a> git 命令脑图</h2> <p><a href="https://blog.csdn.net/kaimo313/article/details/108584389" target="_blank" rel="noopener noreferrer">git 命令脑图链接<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <h2 id="基本概念"><a href="#基本概念" class="header-anchor">#</a> 基本概念</h2> <p><img src="https://img-blog.csdnimg.cn/20200917184011887.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2thaW1vMzEz,size_16,color_FFFFFF,t_70#pic_center" alt="在这里插入图片描述"></p> <p>基于上面的图，我们就有接下来一些概念</p> <h3 id="版本库-git"><a href="#版本库-git" class="header-anchor">#</a> 版本库 <code>.git</code></h3> <ul><li>当我们使用git管理文件时，比如 <code>git init</code> 时，这个时候，会多一个 <code>.git</code> 文件，我们把这个文件称之为版本库。</li> <li><code>.git</code> 文件另外一个作用就是它在创建的时候，会自动创建 master 分支，并且将 HEAD 指针指向 master 分支。</li></ul> <h3 id="工作区"><a href="#工作区" class="header-anchor">#</a> 工作区</h3> <ul><li>本地项目存放文件的位置</li> <li>可以理解成图上的 workspace</li></ul> <h3 id="暂存区-index-stage"><a href="#暂存区-index-stage" class="header-anchor">#</a> 暂存区 (Index/Stage)</h3> <ul><li>顾名思义就是暂时存放文件的地方，通过是通过 add 命令将工作区的文件添加到缓冲区</li></ul> <h3 id="本地仓库-repository"><a href="#本地仓库-repository" class="header-anchor">#</a> 本地仓库（Repository）</h3> <ul><li>通常情况下，我们使用 commit 命令可以将暂存区的文件添加到本地仓库</li> <li>通常而言，HEAD 指针指向的就是 master 分支</li></ul> <h3 id="远程仓库-remote"><a href="#远程仓库-remote" class="header-anchor">#</a> 远程仓库（Remote）</h3> <ul><li>举个例子，当我们使用 GitHub 托管我们项目时，它就是一个远程仓库。</li> <li>通常我们使用 clone 命令将远程仓库代码拷贝下来，本地代码更新后，通过 push 托送给远程仓库。</li></ul> <h2 id="git文件状态"><a href="#git文件状态" class="header-anchor">#</a> Git文件状态</h2> <p>通常我们需要查看一个文件的状态</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> status
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><code>Changes not staged for commit</code></p> <blockquote><p>表示得大概就是工作区有该内容，但是缓存区没有，需要我们 git add</p></blockquote> <p><code>Changes to be committed</code></p> <blockquote><p>一般而言，这个时候，文件放在缓存区了，我们需要git commit</p></blockquote> <p><code>nothing to commit, working tree clean</code></p> <blockquote><p>这个时候，我们将本地的代码推送到远端即可</p></blockquote> <h2 id="常见命令"><a href="#常见命令" class="header-anchor">#</a> 常见命令</h2> <h3 id="git-配置命令"><a href="#git-配置命令" class="header-anchor">#</a> git 配置命令</h3> <p><img src="https://img-blog.csdnimg.cn/20200917184033946.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2thaW1vMzEz,size_16,color_FFFFFF,t_70#pic_center" alt="在这里插入图片描述"></p> <p>列出当前配置</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> config --list   
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>列出 Repository 配置</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> config --local --list
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>列出系统配置</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> config --system --list
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>通过上述的命令，发现你并没有配置用户信息的话，接下来配置一下</p> <p>配置用户名</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> config --global user.name <span class="token string">&quot;your name&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>配置用户邮箱</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> config --global user.email <span class="token string">&quot;youremail@github.com&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="分支管理"><a href="#分支管理" class="header-anchor">#</a> 分支管理</h3> <p><img src="https://img-blog.csdnimg.cn/20200917184048506.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2thaW1vMzEz,size_16,color_FFFFFF,t_70#pic_center" alt="在这里插入图片描述"></p> <p>查看本地分支</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> branch
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>查看远程分支</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> branch -r
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>查看本地和远程分支</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> branch -a
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>从当前分支，切换到其他分支</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> checkout <span class="token operator">&lt;</span>branch-name<span class="token operator">&gt;</span>
// 举个例子
<span class="token function">git</span> checkout feature/tiantian
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>创建并切换到新建分支</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> checkout -b <span class="token operator">&lt;</span>branch-name<span class="token operator">&gt;</span>
// 举个例子
<span class="token function">git</span> checkout -b feature/tiantian
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>删除分支</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> branch -d <span class="token operator">&lt;</span>branch-name<span class="token operator">&gt;</span>
// 举个例子
<span class="token function">git</span> branch -d feature/tiantian
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>当前分支与指定分支合并</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> merge <span class="token operator">&lt;</span>branch-name<span class="token operator">&gt;</span>
// 举个例子
<span class="token function">git</span> merge feature/tiantian
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>查看哪些分支已经合并到当前分支</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> branch --merged
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>查看哪些分支没有合并到当前分支</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> branch --no-merged
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>查看各个分支最后一个提交对象的信息</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> branch -v
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>删除远程分支</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> push origin -d <span class="token operator">&lt;</span>branch-name<span class="token operator">&gt;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>重命名分支</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> branch -m <span class="token operator">&lt;</span>oldbranch-name<span class="token operator">&gt;</span> <span class="token operator">&lt;</span>newbranch-name<span class="token operator">&gt;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>拉取远程分支并创建本地分支</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> checkout -b 本地分支名x origin/远程分支名x

// 另外一种方式,也可以完成这个操作。
<span class="token function">git</span> fetch origin <span class="token operator">&lt;</span>branch-name<span class="token operator">&gt;</span>:<span class="token operator">&lt;</span>local-branch-name<span class="token operator">&gt;</span>
// fetch这个指令的话,后续会梳理
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><h3 id="fetch-指令"><a href="#fetch-指令" class="header-anchor">#</a> fetch 指令</h3> <p><img src="https://img-blog.csdnimg.cn/20200917184107262.png#pic_center" alt="在这里插入图片描述"></p> <p><strong>fetch推荐写法</strong></p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> fetch origin <span class="token operator">&lt;</span>branch-name<span class="token operator">&gt;</span>:<span class="token operator">&lt;</span>local-branch-name<span class="token operator">&gt;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>一般而言，这个 origin 是远程主机名，一般默认就是 origin。</li> <li><code>branch-name</code> 你要拉取的分支</li> <li><code>local-branch-name</code> 通常而言，就是你本地新建一个新分支，将 origin 下的某个分支代码下载到本地分支。</li></ul> <p>举个例子</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> fetch origin feature/template_excellent:feature/template_layout
// 你的工作目录下，就会有feature/template_layout
// 一般情况下,我们需要做的就是在这个分支上开发新需求
// 完成代码后,我们需要做的就是上传我们的分支
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p><strong>fetch其他写法</strong></p> <p>将某个远程主机的更新，全部取回本地。</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> fetch <span class="token operator">&lt;</span>远程主机名<span class="token operator">&gt;</span> 
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>这样子的话，取回的是所有的分支更新，如果想取回特定分支，可以指定分支名</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> fetch <span class="token operator">&lt;</span>远程主机名<span class="token operator">&gt;</span> <span class="token operator">&lt;</span>分支名<span class="token operator">&gt;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>当你想将某个分支的内容取回到本地下某个分支的话，如下</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> fetch origin :<span class="token operator">&lt;</span>local-branch-name<span class="token operator">&gt;</span>
// 等价于
<span class="token function">git</span> fetch origin master:<span class="token operator">&lt;</span>local-branch-name<span class="token operator">&gt;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="花式撤销"><a href="#花式撤销" class="header-anchor">#</a> 花式撤销</h3> <p><img src="https://img-blog.csdnimg.cn/2020091718412239.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2thaW1vMzEz,size_16,color_FFFFFF,t_70#pic_center" alt="在这里插入图片描述"></p> <p>撤销工作区修改</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> checkout --
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>暂存区文件撤销 (不覆盖工作区)</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> reset HEAD
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>版本回退</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> reset --<span class="token punctuation">(</span>soft <span class="token operator">|</span> mixed <span class="token operator">|</span> hard <span class="token punctuation">)</span> <span class="token operator">&lt;</span> HEAD ~<span class="token punctuation">(</span>num<span class="token punctuation">)</span> <span class="token operator">&gt;</span> <span class="token operator">|</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><table><thead><tr><th>指令</th> <th>作用范围</th></tr></thead> <tbody><tr><td>--hard</td> <td>回退全部，包括HEAD，index，working tree</td></tr> <tr><td>--mixed</td> <td>回退部分,包括HEAD，index</td></tr> <tr><td>--soft</td> <td>只回退HEAD</td></tr></tbody></table> <h3 id="状态查询"><a href="#状态查询" class="header-anchor">#</a> 状态查询</h3> <p>展示Git命令大纲</p> <ul><li><code>git help (--help)</code></li></ul> <p>展示Git命令大纲全部列表</p> <ul><li><code>git help -a</code></li></ul> <p>展示具体命令说明手册</p> <ul><li><code>git help</code></li></ul> <h3 id="文件暂存"><a href="#文件暂存" class="header-anchor">#</a> 文件暂存</h3> <p><img src="https://img-blog.csdnimg.cn/2020091718414032.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2thaW1vMzEz,size_16,color_FFFFFF,t_70#pic_center" alt="在这里插入图片描述"></p> <p>添加改动到 stash</p> <ul><li><code>git stash save -a “message”</code></li></ul> <p>删除暂存</p> <ul><li><code>git stash drop stash@{ID}</code></li></ul> <p>删除全部缓存</p> <ul><li><code>git stash clear</code></li></ul> <p>恢复改动</p> <ul><li><code>git stash pop stash@{ID}</code></li></ul> <h3 id="差异比较"><a href="#差异比较" class="header-anchor">#</a> 差异比较</h3> <p><img src="https://img-blog.csdnimg.cn/20200917184156160.png#pic_center" alt="在这里插入图片描述"></p> <p>比较工作区与缓存区</p> <ul><li><code>git diff</code></li></ul> <p>比较缓存区与本地库最近一次commit内容</p> <ul><li><code>git diff -- cached</code></li></ul> <p>比较工作区与本地最近一次commit内容</p> <ul><li><code>git diff HEAD</code></li></ul> <p>比较两个commit之间差异</p> <ul><li><code>git diff &lt;commit ID&gt; &lt;commit ID&gt;</code></li></ul> <h2 id="分支命名"><a href="#分支命名" class="header-anchor">#</a> 分支命名</h2> <p><img src="https://img-blog.csdnimg.cn/20200917184215675.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2thaW1vMzEz,size_16,color_FFFFFF,t_70#pic_center" alt="在这里插入图片描述"></p> <h3 id="master-分支"><a href="#master-分支" class="header-anchor">#</a> master 分支</h3> <p>1、主分支，用于部署生产环境的分支，确保稳定性。</p> <p>2、master 分支一般由 develop 以及 hotfix 分支合并，任何情况下都不能直接修改代码。</p> <h3 id="develop-分支"><a href="#develop-分支" class="header-anchor">#</a> develop 分支</h3> <p>1、develop 为开发分支，通常情况下，保存最新完成以及 bug 修复后的代码。</p> <p>2、开发新功能时，feature 分支都是基于 develop 分支下创建的。</p> <h3 id="feature-分支"><a href="#feature-分支" class="header-anchor">#</a> feature 分支</h3> <p>1、开发新功能，基本上以 develop 为基础创建 feature 分支。</p> <p>2、分支命名：<code>feature/</code> 开头的为特性分支， 命名规则: <code>feature/user_module</code>、 <code>feature/cart_module</code>。</p> <h3 id="release-分支"><a href="#release-分支" class="header-anchor">#</a> release 分支</h3> <p>1、release 为预上线分支，发布提测阶段，会 release 分支代码为基准提测。</p> <h3 id="hotfix-分支"><a href="#hotfix-分支" class="header-anchor">#</a> hotfix 分支</h3> <p>1、分支命名：<code>hotfix/</code> 开头的为修复分支，它的命名规则与 feature 分支类似。</p> <p>2、线上出现紧急问题时，需要及时修复，以 master 分支为基线，创建 hotfix 分支，修复完成后，需要合并到 master 分支和 develop 分支。</p> <h2 id="基本操作"><a href="#基本操作" class="header-anchor">#</a> 基本操作</h2> <p>有了上述的基本了解后，那么我们就来看看整体的一个流程吧。</p> <ul><li>创建本地仓库 git init</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> init
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>链接本地仓库与远端仓库</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> remote <span class="token function">add</span> origin

origin 默认是远端仓库别名 url 可以是可以使用 https 或者 <span class="token function">ssh</span> 的方式新建
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>检查配置信息</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> config --list
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>Git user name 与email</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> config --global user.name <span class="token string">&quot;yourname&quot;</span>

<span class="token function">git</span> config --global user.email <span class="token string">&quot;your_email&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>生成SSH密钥</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>ssh-keygen -t rsa -C <span class="token string">&quot;这里换上你的邮箱&quot;</span>

<span class="token builtin class-name">cd</span> ~/.ssh 里面有一个文件名为 id_rsa.pub,把里面的内容复制到 <span class="token function">git</span> 库的我的 SSHKEYs 中
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>常看远端仓库信息</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> remote -v
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>远端仓库重新命名</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> remote <span class="token function">rename</span> old new
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>提交到缓存区</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> <span class="token function">add</span> <span class="token builtin class-name">.</span> 全部上传到缓存区

<span class="token function">git</span> <span class="token function">add</span> 指定文件
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>提交到本地仓库</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> commit -m <span class="token string">'some message'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>提交远程仓库</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> push <span class="token operator">&lt;</span>远程主机名<span class="token operator">&gt;</span> <span class="token operator">&lt;</span>本地分支名<span class="token operator">&gt;</span>:<span class="token operator">&lt;</span>远程分支名<span class="token operator">&gt;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>查看分支</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> branch
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>创建新分支</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> branch
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>切换分支</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> checkout
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="忽略文件-gitignore"><a href="#忽略文件-gitignore" class="header-anchor">#</a> 忽略文件 .gitignore</h2> <p>这个文件的作用，会去忽略一些不需要纳入 Git 管理这种，我们也不希望出现在未跟踪文件列表。</p> <p>那么我们来看看如何配置该文件信息。</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 此行为注释 会被Git忽略</span>

<span class="token comment"># 忽略 node_modules/ 目录下所有的文件</span>
node_modules


<span class="token comment"># 忽略所有.vscode结尾的文件</span>
.vscode

<span class="token comment"># 忽略所有.md结尾的文件</span>
*.md

<span class="token comment"># 但README.md 除外</span>
<span class="token operator">!</span>README.md

<span class="token comment"># 会忽略 doc/something.txt 但不会忽略doc/images/arch.txt</span>
doc/*.txt

<span class="token comment"># 忽略 doc/ 目录下所有扩展名为txt文件</span>

doc/**/*.txt
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br></div></div></div></div> <div class="page-edit"><div class="tags"><a href="/tags/?tag=git" title="标签">#git</a></div> <!----></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/resource-tools/7566c0ff5a24c/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">Jony的博客</div></a> <a href="/resource-tools/8396c1c08f1b6/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">一些前端开发的干货</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/resource-tools/7566c0ff5a24c/" class="prev">Jony的博客</a></span> <span class="next"><a href="/resource-tools/8396c1c08f1b6/">一些前端开发的干货</a>→
      </span></p></div></div></div> <div class="theme-vdoing-wrapper article-list bg-style-6"><div class="article-title"><a href="/archives/" class="fa fa-pencil-alt">
      最近更新
    </a></div> <div class="article-wrapper"><dl><dd>01</dd> <dt><div><a href="/pages/512f6ae339a31/"><div>【TypesScript主题月】5.7</div></a></div> <div class="date"><span>2021/05/06 00:00:00</span></div></dt></dl><dl><dd>02</dd> <dt><div><a href="/pages/136f8f068dffe/"><div>【React主题月】4月完结</div></a></div> <div class="date"><span>2021/04/30 00:00:00</span></div></dt></dl><dl><dd>03</dd> <dt><div><a href="/pages/55e7bb3eb7802/"><div>【算法打卡】先来一个波集合</div></a></div> <div class="date"><span>2021/04/22 00:00:00</span></div></dt></dl> <div class="more-box"><a href="/archives/" class="more"><i class="fas fa-angle-double-right"></i>前往更多 ...
      </a></div></div></div> <div class="comments-wrapper" style="display:none;"><!----></div></main></div> <div class="footer-wrapper" data-v-51417878 data-v-51417878><span class="footer-reco-theme" data-v-51417878><i class="iconfont reco-github" data-v-51417878></i> <a target="blank" href="https://github.com/alexwjj/alexwjj.github.io" data-v-51417878>alexwjj.github.io@5.0</a></span> <!----> <span class="footer-copyright" data-v-51417878><i class="iconfont reco-copyright" data-v-51417878></i> <a data-v-51417878><span data-v-51417878>俊劫</span> <span class="ml5" data-v-51417878>
          2018 - 2021
        </span></a></span> <span class="footer-view-site" data-v-51417878><i class="iconfont reco-eye" data-v-51417878></i> <span id="busuanzi_container_site_uv" data-v-51417878>
        访客数：<span id="busuanzi_value_site_uv" class="num" data-v-51417878>-</span></span> <span id="busuanzi_container_site_pv" class="ml5" data-v-51417878>
        访问量：<span id="busuanzi_value_site_pv" class="num" data-v-51417878>-</span></span></span> <!----></div> <!----></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div><!----><div></div></div></div>
    <script src="/assets/js/app.070ad525.js" defer></script><script src="/assets/js/2.1d15da37.js" defer></script><script src="/assets/js/59.b74c2845.js" defer></script><script src="/assets/js/4.aab0e518.js" defer></script>
  </body>
</html>
